package cn.tedu.egmvcboot1.common.result;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class JsonResult {
    @ApiModelProperty(value = "状态码",required = true,example = "10100")
    private Integer code;
    @ApiModelProperty(value = "描述信息",required = true,example = "操作成功")
    private String msg;
    @ApiModelProperty(value = "响应数据")
    private Object data;

    public JsonResult(StatusCode statusCode,Object data) {
        this.code = statusCode.getStatusCode();
        this.msg = statusCode.getMessage();
        this.data = data;
    }

    public JsonResult(StatusCode statusCode){
        this(statusCode,null);
    }

    public static JsonResult success(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }

    public static JsonResult success(){
        return success(null);
    }
}
